package src.com.doit.demo02;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class TEST {
    public static void main(String[] args) {
        Map<Integer,String> map = new HashMap<>();
//        map=new TreeMap<>();
//        map=new LinkedHashMap<>();
        map.put(null,null);
        map.put(13,"是");
        System.out.println(map);
        System.out.println(map.get(13));
        System.out.println(map.remove(13));
        System.out.println(map.remove(null));
        System.out.println(map);
        map.put(15,"jinzi");
        map.put(15,"shizi");//键相同 覆盖旧的值
        System.out.println(map);
        System.out.println(map.keySet());//获得所有键
        System.out.println(map.entrySet());

        Set<Integer> set = map.keySet();
        Iterator<Integer> key = set.iterator();
        while (key.hasNext())
        {
            Integer s = key.next();
            System.out.println(s+map.get(s));
        }

        for (Integer keys:set)
        {
            System.out.println(keys+map.get(keys));
        }

    }
}
